import { createApp } from 'vue'
import './style.css'
import './assets/css/global.css' // Import global CSS for Element Plus overrides
import App from './App.vue'
import { createPinia } from 'pinia'
// Import router
import router from './router'

// Import Element Plus
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
// Import Element Plus icons
import * as ElementPlusIconsVue from '@element-plus/icons-vue'

// 导入自定义插件
import routeRecovery from './plugins/routeRecovery'
import sessionWatcher from './plugins/sessionWatcher'

const app = createApp(App)

// Register all Element Plus icons globally
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

// 使用pinia状态管理
const pinia = createPinia()
app.use(pinia)

// 注册Element Plus
app.use(ElementPlus)

// 使用路由恢复插件（必须在router之前注册）
app.use(routeRecovery, { router })

// 添加会话监视插件（必须在pinia之后注册）
app.use(sessionWatcher)

// 注册路由
app.use(router) 

// 挂载应用
app.mount('#app')
